package com.mingjie.daydayup;

import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import receiver.SDCardReceiver;

public class SDCardActivity extends AppCompatActivity {

    private SDCardReceiver sdCardReceiver;

    @Override
    protected void onStart() {
        super.onStart();
        IntentFilter intentFilter= new IntentFilter();
        intentFilter.addAction(SDCardReceiver.MEDIA_MOUNTED);
        intentFilter.addAction(SDCardReceiver.MEDIA_UNMOUNTED);
        intentFilter.addAction(SDCardReceiver.MEDIA_REMOVED);
        intentFilter.setPriority(Integer.MAX_VALUE);
        sdCardReceiver = new SDCardReceiver();
        this.registerReceiver(sdCardReceiver,intentFilter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sdcard);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.unregisterReceiver(sdCardReceiver);
    }
}
